package com.googlecode.maven.plugin.appassembler;

import java.io.File;
import org.apache.commons.lang.SystemUtils;

/**
 * Utility methods.
 */
public final class Utils
    {
    /**
     * Creates a new Utils object.
     */
    private Utils()
        {
        super();
        }

    /**
     * Adds an executable file to the application and changes the mode of the
     * file to executable.
     *
     * @param app The application.
     * @param path Relative path of the file.
     * @param targetDirectory Target directory.
     */
    public static void addExecutableFile(App app, String path,
            File targetDirectory)
        {
        app.getExecutableFiles().add(path);
        if (SystemUtils.IS_OS_UNIX)
            {
            File targetFile = new File(targetDirectory, path);
            FileSystemUtils.chmod(targetFile, "0755", false);
            }
        }
    }
